<?php
/**
 * 登录后所有控制器访问都要经过的控制器
 */
namespace Home\Controller;
use Think\Controller;
class AController extends Controller {
    public function _initialize(){
        $nav_id = I('nav_id');
        if($nav_id){
            //查询当前菜单名称
            $menu = M('menu')->where('id='.$nav_id)->find();
            //查询父菜单
            $parent=M('menu')->where('id='.$menu['pid'])->find();
            //dump($menu);dump($parent);
            if(LANG_SET == 'zh-cn'){
                $this->assign('nav1',$parent['name']);
                $this->assign('nav2',$menu['name']);
            }else{
                $this->assign('nav1',$parent['name_us']);
                $this->assign('nav2',$menu['name_us']);
            }
            $this->assign('nav_id',$nav_id);
            //
            $this->assign('nav_one',$parent);
            $this->assign('nav_two',$menu);
        }
    }
    //获取当前管理员所属机构或分组
    public function getAdminGroup(){
        //判断用户是否登录
        $user = $_SESSION['user'];
        if(!$user){
            $this->error(L('_LOGIN_BEFORE'),U('Login/login'));
        }
        return $user['group'];
    }
}